//
//  UIBarButtonItem.swift
//  WeiBoApp
//
//  Created by CrazyHacker on 16/6/30.
//  Copyright © 2016年 CrazyHacker. All rights reserved.
//

import Foundation

extension UIBarButtonItem {
    
    convenience init(title:String, fontSize: CGFloat = 16,normalColor: UIColor = UIColor.darkGray(),hightlightedColor: UIColor = UIColor.darkGray(), target: AnyObject?, action: Selector, isBack: Bool = false) {
        
        let button: UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: normalColor, highlightedColor: hightlightedColor)
        if isBack {
          let imageName = "navigationbar_back_withtext"
         
            button.setImage(UIImage(named: imageName), for: UIControlState(rawValue:0))
            
            button.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
                
            button.sizeToFit()
        }
         button.addTarget(target, action: action, for: .touchUpInside)
        
        self.init(customView:button)
    }
    
    
}
